{% extends 'shop/base.html' %}

{% block title %}添加商品到购物车{% endblock %}

{% block content %}
<h1 class="mb-6 text-3xl">添加商品到购物车</h1>

<div class="w-1/2 my-6 mx-auto p-6 bg-gray-100 rounded-xl">
    <div class="col-span-3 space-y-6">
        <a href="{% url 'item:detail' item.id %}">
            <div class="p-6 flex bg-gray-100 rounded-xl">
                <div class="pr-6">
                    <img src="{{ item.get_image_url }}" class="w-20 rounded-xl">
                </div>
                <div>
                    <p>{{ item.name }} (卖家：{{ item.created_by }})</p>
                    <p class="mb-4">价格：{{ item.price }} 元</p>
                    {% if item.description %}
                    <p class="text-gray-700">
                        <strong class="text-gray-500">详细情况</strong><br>
                        {{ item.description }}
                    </p>
                    {% endif %}
                </div>
            </div>
        </a>
    </div>
</div>
<div class="w-1/2 my-6 mx-auto p-6">
    <form action="{% url 'cart_add' item.id %}" method="post">
        {% csrf_token %}
        <input type="number" name="quantity" value="{{ form.quantity.value }}" hidden>
        <input type="submit" value="确认添加"
               class="px-6 py-3 font-semibold bg-blue-500 text-white rounded-xl hover:bg-blue-700">
    </form>
</div>
{% endblock %}